package com.ybzl.common.config.minio;

import org.apache.commons.pool2.BasePooledObjectFactory;
import org.apache.commons.pool2.PooledObject;
import org.apache.commons.pool2.impl.DefaultPooledObject;

public class MinioFactory  extends BasePooledObjectFactory<MinioConn> {
    private String url;

    private String accessKey;

    public String secretKey;

    public MinioFactory(String url,String accessKey,String secretKey){
        this.url = url;
        this.accessKey = accessKey;
        this.secretKey = secretKey;
    }

    /**
     *  创建
     * @return
     * @throws Exception
     */
    @Override
    public MinioConn create() throws Exception {
        return new MinioConn(url,accessKey,secretKey);
    }

    /**
     * 包装
     * @param minioConn
     * @return
     */
    @Override
    public PooledObject<MinioConn> wrap(MinioConn minioConn) {
        return new DefaultPooledObject(minioConn);
    }
}
